package com.moonshineproject.editor
{
	import com.moonshineproject.view.IContentWindow;
	
	import flash.filesystem.File;
	
	import mx.containers.Canvas;
	import mx.controls.HTML;
	
	/*
		Simple chrome-less browser, used for binary file viewing (images etc)
		TODO: Make sure it unloads properly!
	*/
	public class BasicHTMLViewer extends Canvas implements IContentWindow
	{
		[Bindable]
		public var file:File;
		
		protected var browser:HTML;
		
		override public function get label():String
		{
			if (file) return file.name;
			return "Image";
		}
		
		public function get longLabel():String
		{
			if (file) return file.nativePath;
			return "Image";
		}
		
		public function save():void
		{
		}
		
		public function isChanged():Boolean
		{
			return false;
		}
		
		public function isEmpty():Boolean
		{
			return true;
		}
		
		public function open(file:File):void
		{
			this.file = file;
		}
		
		override protected function createChildren():void
		{
			super.createChildren();
			
			browser = new HTML();
			browser.location = file.url;
			
			addChild(browser);
		}
		
	}
}